package com.derek.omshopping.bean.mine;
/**
 * Created by asus on 2016/10/20 23 54.
 * 邮箱:763433963@qq.com
 *//**
 * Created by ThinkPad on 2016/10/20.
 */

import android.content.Context;

import com.derek.omshopping.helper.DatabaseHelper;
import com.j256.ormlite.dao.Dao;

import java.sql.SQLException;
import java.util.List;

public class UserBean  {
    private Context mContext;
    private Dao<LoginDatabaseEntity, Integer> userDao;
    private DatabaseHelper mHelper;

    public UserBean(Context context){
        this.mContext = context;
        mHelper = DatabaseHelper.getInstance(context);
        try {
            userDao =  mHelper.getDao(LoginDatabaseEntity.class);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    /**
     *  增加一条账户信息
     * @param loginBean
     */
    public void add(LoginDatabaseEntity loginBean){
        try {
            userDao.create(loginBean);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    /**
     *  通过phoneNumber获取全部的数据库信息
     */
    public List<LoginDatabaseEntity> getAllBean(){
        try {
            return userDao.queryForAll();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
